package viewcomponents
{
	import flash.display.GradientType;
	import flash.display.Graphics;
	import flash.geom.Matrix;
	
	import mx.containers.Canvas;
	import mx.controls.Label;

	public class MenuButton extends Canvas
	{
		public var caption:String;
		private var _label:Label = new Label();
		private var _clickFunc:Function;
		private var _subMenu:Array;
		private var _clickedOn:Boolean = false;
		 
		public function MenuButton(cap:String, func:Function=null, subM:Array=null)
		{
			super();
			_label.text = caption = cap;
			_label.setStyle("textAlign", "center");
			_label.setStyle("horizontalCenter", 0);
			_label.setStyle("verticalCenter", 0);
			addChild(_label);
			
			buttonMode = true;
			mouseChildren = false;
			mouseEnabled = true;
			
			percentHeight = 100;
			
		}
		
		public function get clickedOn():Boolean{
			return _clickedOn;
		}
		
		override protected function updateDisplayList(w:Number, h:Number) :void
        {
            super.updateDisplayList (w, h);
             var _g:Graphics = graphics;
             var _m:Matrix  = new Matrix();
             _m.createGradientBox (w, h, Math.PI*0.5);
            
             _g.clear ();
            
            // so, draw !
             _g.beginGradientFill (GradientType.LINEAR, [0xcaf290, 0xa1f3b0], [1, 1], [0, 255], _m);
             _g.drawRect(0, 0, w, h);
             _g.endFill();

        } 
		
		public function set clickedOn(value:Boolean):void{
			_clickedOn = value;
		}
		
	}
}